package cn.edu.qfnu.common.validation;

import cn.edu.qfnu.common.paginate.Pagination;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.concurrent.ConcurrentHashMap;

/**
 * OnlineJudge of QF_NU
 * Created by LS on 2017/7/19.
 */
public class Code {

    private ConcurrentHashMap<String, String> codeMap = new ConcurrentHashMap<>();
    private static Code code = new Code();

    private Code () {}

    public static Code getInstence() {
        return code;
    }

    public ConcurrentHashMap<String, String> getCodeMap() {
        return codeMap;
    }

    public void setCodeMap(ConcurrentHashMap<String, String> codeMap) {
        this.codeMap = codeMap;
    }

    public String getCodeNumber() {
        StringBuilder num = new StringBuilder();

        for (int i = 0; i < 6; i++) {
            num.append(String.valueOf((int) Math.floor(Math.random() * 9 + 1)));
        }

        return num.toString();
    }
}
